package com.zx.auth.block.param;

import com.zx.validation.annotation.ParameterValidation;
import com.zx.validation.enums.DateTimeFormatEnum;
import com.zx.validation.enums.ValidateRulesEnum;
import com.zx.validation.groups.Query;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * <p>
 * description: OAuth2授权参数类 <br>
 * create: 2025-11-12 20:00
 * </p>
 *
 * @author
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class OAuth2AuthorizationParam implements Serializable, Query {
    /**
     * 主键ID
     */
    @ParameterValidation(index = 0, desc = "授权ID", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~100")
    private String id;

    /**
     * 注册客户端ID
     */
    @ParameterValidation(index = 0, desc = "客户端ID", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~100")
    private String registeredClientId;

    /**
     * 主体名称
     */
    @ParameterValidation(index = 0, desc = "主体名称", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String principalName;

    /**
     * 授权时间
     */
    @ParameterValidation(index = 0, desc = "授权时间", rules = {ValidateRulesEnum.NULL_DATE}, dateFormat = DateTimeFormatEnum.YEAR)
    private LocalDateTime authorizedAt;

    /**
     * 当前页码
     */
    @ParameterValidation(index = 0, desc = "当前页码", rules = {ValidateRulesEnum.NUMBER_MIN}, numberMin = 1)
    private Long pageNum = 1L;

    /**
     * 每页条数
     */
    @ParameterValidation(index = 0, desc = "每页条数", rules = {ValidateRulesEnum.NUMBER_MIN, ValidateRulesEnum.NUMBER_MAX}, numberMin = 1, numberMax = 1000)
    private Long pageSize = 10L;

    @Override
    public Set<String> getQueryGroupFields() {
        return Set.of("id", "registeredClientId", "principalName", "pageNum", "pageSize");
    }
}